/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package local.utils;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import local.clases.Dato;
/**
 *
 * @author Olenkita
 */
public class SQL {
    private static GlobalJDBCGUI globalJDBC = new GlobalJDBCGUI();
    private static Statement statement =globalJDBC.createStatement();
    
    public static List getContenidoTabla(String dato) throws SQLException {
        String sql= "SELECT nombre_de_usuario, password, id,  type_of_id, "
                + "nombres, apellidos, telefono, email, fecha_de_nacimiento, "
                + "sexo, direccion FROM "+dato+" AS X INNER JOIN locations AS L "
                + "ON (X.locations_id = L.locations_id)";
        List lista = new ArrayList();
        ResultSet recordingResults=
                GlobalJDBCGUI.executeQuery(statement, sql);
        while(recordingResults.next()) {
            String Nombre_de_usuario = recordingResults.getString(1);
            if(recordingResults.wasNull()) {
                Nombre_de_usuario = "";
            }
            String Password = recordingResults.getString(2);
            if(recordingResults.wasNull()) {
                Password = "";
            }
            String Id = recordingResults.getString(3);
            if(recordingResults.wasNull()) {
                Id = "";
            }
            String Type_of_id = recordingResults.getString(4);
            if(recordingResults.wasNull()) {
                Type_of_id = "";
            }
            String Nombres = recordingResults.getString(5);
            if(recordingResults.wasNull()) {
                Nombres = "";
            }
            String Apellidos = recordingResults.getString(6);
            if(recordingResults.wasNull()) {
                Apellidos = "";
            }
            String Telefono = recordingResults.getString(7);
            if(recordingResults.wasNull()) {
                Telefono = "";
            }
                   
            String Email = recordingResults.getString(8);
            if(recordingResults.wasNull()) {
                Email = "";
            }
            String Fecha_de_nacimiento = recordingResults.getString(9);
            if(recordingResults.wasNull()) {
                Fecha_de_nacimiento = "";
            }
            String Sexo = recordingResults.getString(10);
            if(recordingResults.wasNull()) {
                Sexo = "";
            }
            String Direccion = recordingResults.getString(11);
            if(recordingResults.wasNull()) {
                Direccion = "";
            }
            lista.add(new Dato(Nombre_de_usuario, Password, Id, Type_of_id, Nombres, Apellidos, Telefono, Email, Fecha_de_nacimiento, Sexo, Direccion));
        }
        return lista;
    }
}
